home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Purity / Purity #42 (1995-01)(PackMAN)(DE)[WB].zip / Purity #42 (1995-01)(PackMAN)(DE)[WB].adf / Includes3v1 / Includes3v1.lha / DOS / DOS.i < prev    next >
Text File  |  1994-12-04  |  16KB  |  531 lines

  1. {
  2.         DOS.i for PCQ Pascal
  3.  
  4.         Standard C header for AmigaDOS
  5. }
  6.  
  7. {$I   "Include:Exec/Types.i"}
  8.  
  9. Const
  10.  
  11.     DOSNAME     = "dos.library";
  12.  
  13. { Predefined Amiga DOS global constants }
  14.  
  15.     DOSTRUE     = -1;
  16.     DOSFALSE    = 0;
  17.  
  18. { Mode parameter to Open() }
  19.  
  20.     MODE_OLDFILE        = 1005;         { Open existing file read/write
  21.                                           positioned at beginning of file. }
  22.     MODE_NEWFILE        = 1006;         { Open freshly created file (delete
  23.                                           old file) read/write }
  24.     MODE_READWRITE      = 1004;         { Open old file w/exclusive lock }
  25.  
  26. { Relative position to Seek() }
  27.  
  28.     OFFSET_BEGINNING    = -1;           { relative to Begining Of File }
  29.     OFFSET_CURRENT      = 0;            { relative to Current file position }
  30.     OFFSET_END          = 1;            { relative to End Of File }
  31.  
  32.     BITSPERBYTE         = 8;
  33.     BYTESPERLONG        = 4;
  34.     BITSPERLONG         = 32;
  35.     MAXINT              = $7FFFFFFF;
  36.     MININT              = $80000000;
  37.  
  38. { Passed as type to Lock() }
  39.  
  40.     SHARED_LOCK         = -2;           { File is readable by others }
  41.     ACCESS_READ         = -2;           { Synonym }
  42.     EXCLUSIVE_LOCK      = -1;           { No other access allowed }
  43.     ACCESS_WRITE        = -1;           { Synonym }
  44.  
  45. Type
  46.  
  47.     FileHandle  = Address;
  48.     FileLock    = Address;
  49.  
  50.     DateStampRec = record
  51.         ds_Days         : Integer;      { Number of days since Jan. 1, 1978 }
  52.         ds_Minute       : Integer;      { Number of minutes past midnight }
  53.         ds_Tick         : Integer;      { Number of ticks past minute }
  54.     end;
  55.     DateStampPtr = ^DateStampRec;
  56.  
  57. Const
  58.  
  59.     TICKS_PER_SECOND    = 50;           { Number of ticks in one second }
  60.  
  61. Type
  62.  
  63. { Returned by Examine() and ExInfo(), must be on a 4 byte boundary }
  64.  
  65.     FileInfoBlock = record
  66.         fib_DiskKey     : Integer;
  67.         fib_DirEntryType : Integer;
  68.                         { Type of Directory. If < 0, then a plain file.
  69.                           If > 0 a directory }
  70.         fib_FileName    : Array [0..107] of Char;
  71.                         { Null terminated. Max 30 chars used for now }
  72.         fib_Protection  : Integer;
  73.                         { bit mask of protection, rwxd are 3-0. }
  74.         fib_EntryType   : Integer;
  75.         fib_Size        : Integer;      { Number of bytes in file }
  76.         fib_NumBlocks   : Integer;      { Number of blocks in file }
  77.         fib_Date        : DateStampRec; { Date file last changed }
  78.         fib_Comment     : Array [0..79] of Char;
  79.                         { Null terminated comment associated with file }
  80.         fib_Reserved    : Array [0..35] of Char;
  81.     end;
  82.     FileInfoBlockPtr = ^FileInfoBlock;
  83.  
  84.  
  85. Const
  86.  
  87. { FIB stands for FileInfoBlock }
  88.  
  89. { FIBB are bit definitions, FIBF are field definitions }
  90.  
  91.     FIBB_SCRIPT         = 6;    { program is a script (execute) file }
  92.     FIBB_PURE           = 5;    { program is reentrant and rexecutable}
  93.     FIBB_ARCHIVE        = 4;    { cleared whenever file is changed }
  94.     FIBB_READ           = 3;    { ignored by old filesystem }
  95.     FIBB_WRITE          = 2;    { ignored by old filesystem }
  96.     FIBB_EXECUTE        = 1;    { ignored by system, used by Shell }
  97.     FIBB_DELETE         = 0;    { prevent file from being deleted }
  98.     FIBF_SCRIPT         = 64;
  99.     FIBF_PURE           = 32;
  100.     FIBF_ARCHIVE        = 16;
  101.     FIBF_READ           = 8;
  102.     FIBF_WRITE          = 4;
  103.     FIBF_EXECUTE        = 2;
  104.     FIBF_DELETE         = 1;
  105.  
  106.  
  107. Type
  108.  
  109. { returned by Info(), must be on a 4 byte boundary }
  110.  
  111.     InfoData = record
  112.         id_NumSoftErrors        : Integer;      { number of soft errors on disk }
  113.         id_UnitNumber           : Integer;      { Which unit disk is (was) mounted on }
  114.         id_DiskState            : Integer;      { See defines below }
  115.         id_NumBlocks            : Integer;      { Number of blocks on disk }
  116.         id_NumBlocksUsed        : Integer;      { Number of block in use }
  117.         id_BytesPerBlock        : Integer;
  118.         id_DiskType             : Integer;      { Disk Type code }
  119.         id_VolumeNode           : BPTR;         { BCPL pointer to volume node }
  120.         id_InUse                : Integer;      { Flag, zero if not in use }
  121.     end;
  122.     InfoDataPtr = ^InfoData;
  123.  
  124. Const
  125.  
  126. { ID stands for InfoData }
  127.  
  128.         { Disk states }
  129.  
  130.     ID_WRITE_PROTECTED  = 80;   { Disk is write protected }
  131.     ID_VALIDATING       = 81;   { Disk is currently being validated }
  132.     ID_VALIDATED        = 82;   { Disk is consistent and writeable }
  133.  
  134. CONST
  135.  ID_NO_DISK_PRESENT     = -1;
  136.  ID_UNREADABLE_DISK     = $42414400;   { 'BAD\0' }
  137.  ID_DOS_DISK            = $444F5300;   { 'DOS\0' }
  138.  ID_FFS_DISK            = $444F5301;   { 'DOS\1' }
  139.  ID_NOT_REALLY_DOS      = $4E444F53;   { 'NDOS'  }
  140.  ID_KICKSTART_DISK      = $4B49434B;   { 'KICK'  }
  141.  ID_MSDOS_DISK          = $4d534400;   { 'MSD\0' }
  142.  
  143. { Errors from IoErr(), etc. }
  144.  ERROR_NO_FREE_STORE              = 103;
  145.  ERROR_TASK_TABLE_FULL            = 105;
  146.  ERROR_BAD_TEMPLATE               = 114;
  147.  ERROR_BAD_NUMBER                 = 115;
  148.  ERROR_REQUIRED_ARG_MISSING       = 116;
  149.  ERROR_KEY_NEEDS_ARG              = 117;
  150.  ERROR_TOO_MANY_ARGS              = 118;
  151.  ERROR_UNMATCHED_QUOTES           = 119;
  152.  ERROR_LINE_TOO_LONG              = 120;
  153.  ERROR_FILE_NOT_OBJECT            = 121;
  154.  ERROR_INVALID_RESIDENT_LIBRARY   = 122;
  155.  ERROR_NO_DEFAULT_DIR             = 201;
  156.  ERROR_OBJECT_IN_USE              = 202;
  157.  ERROR_OBJECT_EXISTS              = 203;
  158.  ERROR_DIR_NOT_FOUND              = 204;
  159.  ERROR_OBJECT_NOT_FOUND           = 205;
  160.  ERROR_BAD_STREAM_NAME            = 206;
  161.  ERROR_OBJECT_TOO_LARGE           = 207;
  162.  ERROR_ACTION_NOT_KNOWN           = 209;
  163.  ERROR_INVALID_COMPONENT_NAME     = 210;
  164.  ERROR_INVALID_LOCK               = 211;
  165.  ERROR_OBJECT_WRONG_TYPE          = 212;
  166.  ERROR_DISK_NOT_VALIDATED         = 213;
  167.  ERROR_DISK_WRITE_PROTECTED       = 214;
  168.  ERROR_RENAME_ACROSS_DEVICES      = 215;
  169.  ERROR_DIRECTORY_NOT_EMPTY        = 216;
  170.  ERROR_TOO_MANY_LEVELS            = 217;
  171.  ERROR_DEVICE_NOT_MOUNTED         = 218;
  172.  ERROR_SEEK_ERROR                 = 219;
  173.  ERROR_COMMENT_TOO_BIG            = 220;
  174.  ERROR_DISK_FULL                  = 221;
  175.  ERROR_DELETE_PROTECTED           = 222;
  176.  ERROR_WRITE_PROTECTED            = 223;
  177.  ERROR_READ_PROTECTED             = 224;
  178.  ERROR_NOT_A_DOS_DISK             = 225;
  179.  ERROR_NO_DISK                    = 226;
  180.  ERROR_NO_MORE_ENTRIES            = 232;
  181. { added for 1.4 }
  182.  ERROR_IS_SOFT_LINK               = 233;
  183.  ERROR_OBJECT_LINKED              = 234;
  184.  ERROR_BAD_HUNK                   = 235;
  185.  ERROR_NOT_IMPLEMENTED            = 236;
  186.  ERROR_RECORD_NOT_LOCKED          = 240;
  187.  ERROR_LOCK_COLLISION             = 241;
  188.  ERROR_LOCK_TIMEOUT               = 242;
  189.  ERROR_UNLOCK_ERROR               = 243;
  190.  
  191. { error codes 303-305 are defined in dosasl.h }
  192.  
  193. { These are the return codes used by convention by AmigaDOS commands }
  194. { See FAILAT and IF for relvance to EXECUTE files                    }
  195.  RETURN_OK                        =   0;  { No problems, success }
  196.  RETURN_WARN                      =   5;  { A warning only }
  197.  RETURN_ERROR                     =  10;  { Something wrong }
  198.  RETURN_FAIL                      =  20;  { Complete or severe failure}
  199.  
  200. { Bit numbers that signal you that a user has issued a break }
  201.  SIGBREAKB_CTRL_C   = 12;
  202.  SIGBREAKB_CTRL_D   = 13;
  203.  SIGBREAKB_CTRL_E   = 14;
  204.  SIGBREAKB_CTRL_F   = 15;
  205.  
  206. { Bit fields that signal you that a user has issued a break }
  207. { for example:  if (SetSignal(0,0) & SIGBREAKF_CTRL_C) cleanup_and_exit(); }
  208.  SIGBREAKF_CTRL_C   = 4096;
  209.  SIGBREAKF_CTRL_D   = 8192;
  210.  SIGBREAKF_CTRL_E   = 16384;
  211.  SIGBREAKF_CTRL_F   = 32768;
  212.  
  213. { Values returned by SameLock() }
  214.  LOCK_SAME             =  0;
  215.  LOCK_SAME_HANDLER     =  1;       { actually same volume }
  216.  LOCK_DIFFERENT        =  -1;
  217.  
  218. { types for ChangeMode() }
  219.  CHANGE_LOCK    = 0;
  220.  CHANGE_FH      = 1;
  221.  
  222. { Values for MakeLink() }
  223.  LINK_HARD      = 0;
  224.  LINK_SOFT      = 1;       { softlinks are not fully supported yet }
  225.  
  226. { values returned by ReadItem }
  227.  ITEM_EQUAL     = -2;              { "=" Symbol }
  228.  ITEM_ERROR     = -1;              { error }
  229.  ITEM_NOTHING   = 0;               { *N, ;, endstreamch }
  230.  ITEM_UNQUOTED  = 1;               { unquoted item }
  231.  ITEM_QUOTED    = 2;               { quoted item }
  232.  
  233. { types for AllocDosObject/FreeDosObject }
  234.  DOS_FILEHANDLE        =  0;       { few people should use this }
  235.  DOS_EXALLCONTROL      =  1;       { Must be used to allocate this! }
  236.  DOS_FIB               =  2;       { useful }
  237.  DOS_STDPKT            =  3;       { for doing packet-level I/O }
  238.  DOS_CLI               =  4;       { for shell-writers, etc }
  239.  DOS_RDARGS            =  5;       { for ReadArgs if you pass it in }
  240.  
  241.  
  242.  
  243. Procedure DOSClose(filehand : FileHandle);
  244.     External;
  245.  
  246. Function CreateDir(name : String) : FileLock;
  247.     External;
  248.  
  249. Function CurrentDir(lock : FileLock) : FileLock;
  250.     External;
  251.  
  252. Procedure DateStamp(var ds : DateStampRec);
  253.     External;
  254.  
  255. Procedure Delay(ticks : Integer);
  256.     External;
  257.  
  258. Function DeleteFile(name : String) : Boolean;
  259.     External;
  260.  
  261. Function DupLock(lock : FileLock) : FileLock;
  262.     External;
  263.  
  264. Function Examine(lock : FileLock; info : FileInfoBlockPtr) : Boolean;
  265.     External;
  266.  
  267. Function Execute(command : String; InFile, OutFile : FileHandle) : Boolean;
  268.     External;
  269.  
  270. Procedure DOSExit(code : Integer);
  271.     External;
  272.  
  273. Function ExNext(lock : FileLock; info : FileInfoBlockPtr) : Boolean;
  274.     External;
  275.  
  276. Function Info(lock : FileLock; params : InfoDataPtr) : Boolean;
  277.     External;
  278.  
  279. Function IoErr : Integer;
  280.     External;
  281.  
  282. Function DOSInput : FileHandle;
  283.     External;
  284.  
  285. Function IsInteractive(f : FileHandle) : Boolean;
  286.     External;
  287.  
  288. Function Lock(name : String; accessmode : Integer) : FileLock;
  289.     External;
  290.  
  291. Function DOSOpen(name : String; accessmode : Integer) : FileHandle;
  292.     External;
  293.  
  294. Function DOSOutput : FileHandle;
  295.     External;
  296.  
  297. Function ParentDir(lock : FileLock) : FileLock;
  298.     External;
  299.  
  300. Function DOSRead(f : FileHandle; buffer : Address; length : Integer) : Integer;
  301.     External;
  302.  
  303. Function Rename(oldname, newname : String) : Boolean;
  304.     External;
  305.  
  306. Function Seek(f : FileHandle; pos : Integer; mode : Integer) : Integer;
  307.     External;
  308.  
  309. Function SetComment(name : String; comment : String) : Boolean;
  310.     External;
  311.  
  312. Function SetProtection(name : String; mask : Integer) : Boolean;
  313.     External;
  314.  
  315. Procedure UnLock(lock : FileLock);
  316.     External;
  317.  
  318. Function WaitForChar(f : FileHandle; timeout : Integer) : Boolean;
  319.     External;
  320.  
  321. Function DOSWrite(f : FileHandle; buffer : Address; len : Integer) : Integer;
  322.     External;
  323.  
  324.  
  325. { functions in V37 or higher }
  326.  
  327. FUNCTION AddBuffers(Name : String; Buffers : Integer) : Boolean;
  328.     External;
  329.  
  330. FUNCTION AddPart(Path1, Path2 : String; Bytes : Integer) : Boolean;
  331.     External;
  332.  
  333. FUNCTION AllocDosObject(ObjectType : Integer; Tags : Address) : Address;
  334.     External;
  335.  
  336. FUNCTION AssignAdd(name : String; Datei : FileLock) : Boolean;
  337.     External;
  338.  
  339. FUNCTION AssignLate(name1, name2 : String) : Boolean;
  340.     External;
  341.  
  342. FUNCTION AssignLock(name : String; Datei : FileLock) : Boolean;
  343.     External;
  344.  
  345. FUNCTION AssignPath(name1, name2 : String) : Boolean;
  346.     External;
  347.  
  348. FUNCTION ChangeMode(Mode : Integer; Datei : Address; newMode : Integer) : Boolean;
  349.     External;                       { Datei is a FileLock OR a FileHandle }
  350.  
  351. FUNCTION CheckSignal(Signal : Integer) : Integer;
  352.     External;
  353.  
  354. FUNCTION CompareDates(First, Second : DateStampPtr) : Integer;
  355.     External;
  356.  
  357. FUNCTION DupLockFromFH(Datei : FileHandle) : FileLock;
  358.     External;
  359.  
  360. FUNCTION ErrorReport(ErrorCode, ReportType : Integer; Param : Address; HandlerID : Address) : Boolean;
  361.     External;                                                          { HandlerID is a MsgPortPtr }
  362.  
  363. FUNCTION ExamineFH(Datei : FileHandle; FIB : FileInfoBlockPtr) : Boolean;
  364.     External;
  365.  
  366. FUNCTION Fault(Code : Integer; Txt : String; Buffer : String; BufferSize : Integer) : Integer;
  367.     External;
  368.  
  369. FUNCTION FGetC(Datei : FileHandle) : Char;
  370.     External;
  371.  
  372. FUNCTION FGets(Datei : FileHandle; Buffer : String; BufferSize : Integer) : String;
  373.     External;
  374.  
  375. FUNCTION FilePart(Path : String) : Char;
  376.     External;
  377.  
  378. FUNCTION Flush(Datei : FileHandle) : Boolean;
  379.     External;
  380.  
  381. FUNCTION Format(drive, name : String; DOSType : Integer) : Boolean;
  382.     External;
  383.  
  384. FUNCTION FPutC(Datei : FileHandle; c : Char) : Integer;
  385.     External;
  386.  
  387. FUNCTION FPuts(Datei : FileHandle; str : String) : Boolean;
  388.     External;
  389.  
  390. FUNCTION FRead(Datei : FileHandle; Buffer : Address; BlockSize, Blocks : Integer) : Integer;
  391.     External;
  392.  
  393. FUNCTION FWrite(Datei : FileHandle; Buffer : Address; BlockSize, Blocks : Integer) : Integer;
  394.     External;
  395.  
  396. PROCEDURE FreeDosObject(ObjectType : Integer; Object : Address);
  397.     External;
  398.  
  399. FUNCTION GetArgStr : String;
  400.     External;
  401.  
  402. FUNCTION GetCurrentDirName(Buffer : String; BufferSize : Integer) : Boolean;
  403.     External;
  404.  
  405. FUNCTION GetProgramDir : FileLock;
  406.     External;
  407.  
  408. FUNCTION GetProgramName(Buffer : String; BufferSize : Integer) : Boolean;
  409.     External;
  410.  
  411. FUNCTION GetPrompt(Buffer : String; BufferSize : Integer) : Boolean;
  412.     External;
  413.  
  414. FUNCTION Inhibit(device : String; mode : Boolean) : Boolean;
  415.     External;
  416.  
  417. FUNCTION IsFileSystem(name : String) : Boolean;
  418.     External;
  419.  
  420. FUNCTION MakeLink(name : String; datei : Address; LinkType : Integer) : Boolean;
  421.     External;                   { LinkType=LINK_HARD : datei=FileLock
  422.                                 { LinkType=LINK_SOFT : Datei=String }
  423.  
  424. FUNCTION NameFromFH(Datei : FileHandle; Buffer : String; BufferSize : Integer) : Boolean;
  425.     External;
  426.  
  427. FUNCTION NameFromLock(Datei : FileLock; Buffer : String; BufferSize : Integer) : Boolean;
  428.     External;
  429.  
  430. FUNCTION OpenFromLock(Datei : FileLock) : FileHandle;
  431.     External;
  432.  
  433. FUNCTION ParentOfFH(Datei : FileHandle) : FileLock;
  434.     External;
  435.  
  436. FUNCTION PathPart(Path : String) : Char;
  437.     External;
  438.  
  439. FUNCTION PrintFault(error : Integer; Str : String) : Boolean;
  440.     External;
  441.  
  442. FUNCTION PutStr(Str : String) : Boolean;
  443.     External;
  444.  
  445. FUNCTION ReadLink(procID : Address; datei : FileLock; name : String;
  446.                   buffer : String; buffersize : Integer) : Boolean;
  447.     External;     { procID is a MsgPortPtr }
  448.  
  449. FUNCTION Relabel(device : String; newname : String) : Boolean;
  450.     External;
  451.  
  452. FUNCTION RemAssignList(name : String; datei : FileLock) : Boolean;
  453.     External;
  454.  
  455. FUNCTION RunCommand(SL : Address; stacksize : Integer; param : String; paramlen : Integer) : Integer;
  456.     External;
  457.  
  458. FUNCTION SameDevice(datei1, datei2 : FileLock) : Boolean;
  459.     External;
  460.  
  461. FUNCTION SameLock(datei1, datei2 : FileLock) : Integer;
  462.     External;
  463.  
  464. FUNCTION SelectInput(new : FileHandle) : FileHandle;
  465.     External;
  466.  
  467. FUNCTION SelectOutput(new : FileHandle) : FileHandle;
  468.     External;
  469.  
  470. FUNCTION SetArgStr(new : String) : String;
  471.     External;
  472.  
  473. FUNCTION SetCurrentDirName(path : String) : Boolean;
  474.     External;
  475.  
  476. FUNCTION SetFileDate(datei : String; date : DateStampPtr) : Boolean;
  477.     External;
  478.  
  479. FUNCTION SetFileSize(datei : FileHandle; new, mode : Integer) : Boolean;
  480.     External;
  481.  
  482. FUNCTION SetIoErr(new : Integer) : Integer;
  483.     External;
  484.  
  485. FUNCTION SetMode(datei : FileHandle; new : Integer) : Boolean;
  486.     External;
  487.  
  488. FUNCTION SetProgramDir(new : FileLock) : FileLock;
  489.     External;
  490.  
  491. FUNCTION SetProgramName(new : String) : Boolean;
  492.     External;
  493.  
  494. FUNCTION SetPrompt(prompt : String) : Boolean;
  495.     External;
  496.  
  497. FUNCTION SetVBuf(datei : FileHandle; Buffer : String; bufmode, buffersize : Integer) : Boolean;
  498.     External;
  499.  
  500. FUNCTION SplitName(path : String; Separator : Char; Buffer : String; start : Short; BufferSize : Integer) : Short;
  501.     External;
  502.  
  503. FUNCTION StrToLong(Str : String; L : Address) : Integer;
  504.     External;
  505.  
  506. FUNCTION SystemTagList(command : String; tags : Address) : Integer;
  507.     External;
  508.  
  509. FUNCTION UnGetC(Datei : FileHandle; c : Integer) : Integer;
  510.     External;
  511.  
  512. FUNCTION VFPrintf(datei : FileHandle; str : String; objects : Address) : Integer;
  513.     External;
  514.  
  515. FUNCTION VFWritef(datei : FileHandle; str : String; objects : Address) : Integer;
  516.     External;
  517.  
  518. FUNCTION VPrintf(str : String; objects : Address) : Integer;
  519.     External;
  520.  
  521. FUNCTION WriteChars(buffer : String; num : Integer) : Integer;
  522.     External;
  523.  
  524. { functions in V39 or higher }
  525.  
  526. FUNCTION SetOwner(name : String; owner_info : Integer) : Boolean;
  527.     External;
  528.  
  529.  
  530.  
  531.